from datetime import datetime
import random


__all__ = ["generate_id", "random_account"]


def generate_id(flag: str = "") -> str:
    # 获取当前时间
    now = datetime.now()
    # 格式化为指定的ID格式
    id_format = now.strftime("%Y%m%d%H%M%S%f")
    return flag + id_format


def random_account() -> str:
    # 首位数字不能为0且不能为4，范围是1-3或5-9
    first_digit = random.choice('12356789')
    # 剩下的8位数字不能包含4
    remaining_digits = ''.join(random.choice('012356789') for _ in range(8))
    # 拼接首位和剩余8位数字
    random_number_string = first_digit + remaining_digits
    return random_number_string